package gaobo.genericity;


import java.awt.*;
import java.util.*;
import java.util.List;

class Student implements Comparable<Student>{
    private int age;
    private String name;
    private double score;

    public Student(int age, String name, double score) {
        this.age = age;
        this.name = name;
        this.score = score;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        //高-》低
        return (int)(o.score-this.score);
    }
}

public class Test1 {

    public static ArrayList<Character> func(String str1,String str2){
        ArrayList<Character> arrayList = new ArrayList<>();
        for (int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
            if (!str2.contains(ch+"")){
                arrayList.add(ch);
            }
        }
        return arrayList;
    }

    public static void main(String[] args) {
        //删除相同字符串
        ArrayList<Character> ret = func("welcome to bit","come");
        for (int i = 0; i < ret.size(); i++) {
            System.out.print(ret.get(i));
        }

    }


    public static void main4(String[] args) {
        //成绩表排序
        ArrayList<Student> arrayList = new ArrayList<>();
        arrayList.add(new Student(10,"小王",49.9));
        arrayList.add(new Student(11,"小红",39.9));
        arrayList.add(new Student(12,"小花",89.9));

        for (Student s: arrayList) {
            System.out.println(s);
        }
        System.out.println("======");
        Collections.sort(arrayList);
        for (Student s: arrayList) {
            System.out.println(s);

        }
    }

    public static void main3(String[] args) {
        //顺序表遍历
        ArrayList<Integer> arrayList1 = new ArrayList<>();
        arrayList1.add(1);
        arrayList1.add(2);
        arrayList1.add(3);
        arrayList1.add(4);
        arrayList1.add(5);
        int size = arrayList1.size();
        //fori
        for (int i = 0; i < size; i++) {
            System.out.print(arrayList1.get(i)+" ");
        }
        System.out.println();
        //foreach
        for (Integer x:
             arrayList1) {
            System.out.print(x+" ");
        }
        System.out.println();
        //迭代器
        Iterator<Integer> it = arrayList1.iterator();
        while (it.hasNext()){
            System.out.print(it.next()+" ");
        }
        System.out.println();
        //直接打印
        System.out.println(arrayList1);



    }


    public static void main2(String[] args) {
        ArrayList<Integer> arrayList1 = new ArrayList<>();
        arrayList1.add(1);
        arrayList1.add(2);
        arrayList1.add(3);
        arrayList1.add(4);
        arrayList1.add(5);
        //截取
        List<Integer> list = arrayList1.subList(1,3);
        System.out.println(list);//2,3

        System.out.println("===============");
        list.set(0,99);
        System.out.println(arrayList1);
        System.out.println(list);

        arrayList1.add(2);
        arrayList1.add(0,7);
        System.out.println(arrayList1);
        arrayList1.remove(new Integer(7));
        System.out.println(arrayList1);
        arrayList1.clear();
        System.out.println(arrayList1);




        //构造方法
        ArrayList<Integer> arrayList2 = new ArrayList<>(12);
        arrayList2.add(2);
        arrayList2.add(3);
        arrayList2.add(4);
        System.out.println(arrayList2);

        LinkedList<Integer> arrayList4 = new LinkedList<>();

        ArrayList<Integer> arrayList3 = new ArrayList<>(arrayList4);



    }
}
